package IA;

import java.util.Collections;
import java.util.Iterator;
import java.util.ArrayList;

/**
 *
 * @author Jeremy
 */
public class HighestPrepTimeCookStrategy implements CookStrategy {

    @Override
    public ArrayList<CookItem> getNextOrders(ArrayList<CookItem> cookingItems, ArrayList<CookItem> queueItems, int NumNeeded) {
        int numFetched = 0;
        ArrayList<CookItem> ItemsToReturn = new ArrayList<CookItem>();
        ArrayList<CookItem> queue = (ArrayList<CookItem>) queueItems.clone();
        Collections.sort(queue, CookItem.getHighestFirstPrepTimeComparator());
        Iterator<CookItem> itr = queue.iterator();
        while (numFetched < NumNeeded && itr.hasNext()) {
            ItemsToReturn.add(itr.next());
            numFetched++;
        }
        return ItemsToReturn;
    }
}
